<template>
	<view class="wrap-box" v-if="addonIsExit.fenxiao!=0 && isFenxiao ">
		<view class="wrap" @click="goodsFx">
			<view class="left">
				返
			</view>
			<view class="right">
				<view class="ns-text-color">￥{{levelInfo.commission_money}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import globalConfig from '@/common/js/golbalConfig.js';
	export default {
		name: 'ns-fenxiao-good-detail',
		props: {
			skuId: {
				type: [Number,String],
				default: 0
			}
		},
		mixins:[globalConfig],
		data() {
			return {
				isIphoneX: false,
				//是否开启预览，0：不开启，1：开启
				preview: 0,
				fenXiaoLevel: 0,
				levelId:0,
				levelInfo:{},
				token:"",
				
				isFenxiao:false
			};
		},
		async created() {
			if(!uni.getStorageSync("token")) return;
			this.isIphoneX = this.$util.uniappIsIPhoneX();
			if(this.addonIsExit.fenxiao!=0){
				this.getFenxiaoDetail()
				this.getFenxiaoGoodsDetail();
			}
		},
		
		mounted() {
			
		},
		methods: {
			//判断是否有分销插件
			goodsFx(){
				this.$emit("goodsFx", {showFenxiao:this.addonIsExit.fenxiao,words_account:this.isFenxiao})
			},
			//请求分销商信息
			getFenxiaoDetail() {
				this.$api.sendRequest({
					url: '/fenxiao/api/fenxiao/detail',
					success: res => {
						if (res.data) {
							this.isFenxiao=true;
						} else {
							this.isFenxiao=false;
						}
						this.goodsFx()
					},
					fail:res=>{
						this.isFenxiao=false;
					}
				});
			},
			//获取分销返佣详情
			getFenxiaoGoodsDetail() {
				this.$api.sendRequest({
					url: '/fenxiao/api/goods/detail',
					data:{
						sku_id:this.skuId,
					},
					success: res => {
						if(res.code==0&&res.data){
							this.levelInfo=res.data
						}
						this.$forceUpdate()
					}
				});
			}
		}
	};
</script>

<style lang="scss">
	.wrap{
		display: flex;
		flex-direction: row;
		justify-content: center;
		border: 3rpx solid $base-color;
		border-radius: 5rpx;
		.left{
			flex: 2;
			background-color: $base-color;
			color: #FFFFFF;
			font-size: $ns-font-size-base;
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.right{
			flex: 3;
			color: $base-color;
			font-size: $ns-font-size-base;
		}
	}
</style>
